<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加员工</title>
    <link rel="stylesheet" href="/asset/layui/css/layui.css">
    <link rel="stylesheet" href="/asset/css/index.css">
    <link rel="Shortcut Icon" href="cachet.ico">
    <script type="text/javascript" src="/asset/js/jquery-3.3.1.min.js"></script>
	<script src="/asset/layui/layui.js"></script>
    <script src="/asset/js/common.js"></script>
</head>
<body>
<style type="text/css">
	.content{
		width: auto;
		display: block;
	}
	.content .left{
		float: left;
		width: 200px;
		margin: 0px 8px 0 0;
		border: 1px solid #f4f6f5;
		background: #fff;
		padding-left: 8px;
		
	}
	
   .content .right{
    		border: 1px solid #f4f6f5;
	    background: #fff;
	    position:relative; 
	    overflow:hidden;
    }
    .footer{
		
		text-align: center;
		margin-top: 10px;
		background-color: #E3E3E3;
	}
</style>
<div class="layui-body">
	<div class="body_right">
		<h4 class="nav_title">员工管理
         </h4>
		<div class="content">
			<div class="left">
				<iframe name="left"  id="leftMain" src="/staff/orgs.htm" id="center_frame" src="" frameborder="false" scrolling="auto" style="border: none; height: 800px;" width="100%" height="auto" allowtransparency="true"></iframe>
			</div>
			<div class="right">
				<iframe name="right" id="rightMain" src="/staff/list.htm" frameborder="false" scrolling="auto" style="border: none;  height: 800px;" width="100%" height="auto" allowtransparency="true"></iframe>
			</div>
		</div>
	</div>	
</div>	
	<script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;

          //监听提交
          form.on('submit(add)', function(data){
            var $custosInfo = parent.$("#custosInfo");
            var addtype = $custosInfo.attr("data");
            
            var $selectedId =  $("#rightMain").contents().find("input[name='selectedId']:checked");
            var selectedId = $selectedId.val(), data = $selectedId.attr("lay-data");
            
            if(!selectedId){
            		layer.msg("请选择保管员");
            }else{
           		var obj =  eval('(' + data + ')');
           		
           		var custosInfo = $([' <div class="user"><input type="hidden" name="partyId" value="'+selectedId+'">'
							          	,'<div class="avatar"><img src="http://img5.duitang.com/uploads/item/201611/13/20161113110506_ScT45.thumb.700_0.jpeg"  /></div>'
							            ,'<div class="info"><div class="name">'+obj.name+'</div><div class="position">'+obj.position+'</div></div>'
							         ,'</div>'].join(''));
			         
			    //判断是否多选
			    if(addtype && addtype=='MULTISELECT'){
			    		$custosInfo.append(custosInfo);
			    
			    }else{
			    		$custosInfo.html(custosInfo);
			    }
			    
			     var index = parent.layer.getFrameIndex(window.name);
           		 parent.layer.close(index);
            
            }
            
            return false;
          });
          
          form.on('submit(cancel)', function(data){
            
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
            
            return false;
          });
          
        });
    </script>
	
	
	
	
	
</body>
</html>